const Sequelize = require('sequelize')
const sequelize = require('../config/index')
const User = require('./user').User
let Bill = sequelize.define('bill',{
    id:{
        type:Sequelize.INTEGER,
        primaryKey: true,
        autoIncrement: true,
        comment:'账单id',
    },
    uid:{
        type:Sequelize.INTEGER,
        defaultValue:'',
        comment:'用户id',
    },
    total_fee:{
        type:Sequelize.INTEGER,

        comment:'支付金额',
    },
    cash_fee:{
        type:Sequelize.INTEGER,

        comment:'实付金额',
    },
    bank_type:{

        type:Sequelize.STRING,
        comment:'支付银行'
    },
    out_trade_no:{
        type:Sequelize.STRING,
        comment:'支付单号',
    },
    time_end:{
        type:Sequelize.STRING,
        comment:'支付时间',
    },
    trade_state_desc:{
        type:Sequelize.STRING,

        comment:'支付状态描述',
    },
    appid:{
        type:Sequelize.STRING,
        comment:'支付openid'
    },
    mch_id:{
        type:Sequelize.STRING,
        comment:'mch_id'
    },
    return_code:{
        type:Sequelize.STRING,
        comment:'支付返回码'
    },
},{
    // freezeTabelName 为 true 时不会在库中映射表时增加复数表名
    // 该选项为 true 时，user 在映射时映射成 user，而为 false 时会映射成users
    freezeTableName: true,
})
Bill.belongsTo(User,{foreignKey: "uid"});
// Skill.belongsToMany(User, {through : 'userSkill'});
//这会创建一个新模型UserProject,其中projectId和userId两个外键。定义through选项后，Sequelize会尝试自动生成名字。
//在本例中，会为User添加方法getUsers,setUsers,addUser,addUsers到Project中。getProjects,setProjects,addProject,addProjects到User中.


let bill = Bill.sync({force:true});

module.exports = Bill

